//
//  HWGameDetailsViewController.m
//  HWPromoteProjectAPP
//
//  Created by 陈道斌 on 2020/3/5.
//  Copyright © 2020 陈道斌. All rights reserved.
//

#import "HWGameDetailsViewController.h"

@interface HWGameDetailsViewController ()<UITableViewDelegate,UITableViewDataSource,UICollectionViewDelegate,UICollectionViewDataSource>
@property(strong,nonatomic) UITableView *mainaTableVie;
@property(strong,nonatomic) UIView *headerView;

@property(strong,nonatomic) UIView *shangmianView;
@property(strong,nonatomic) UIImageView *icoImageView;

@property(strong,nonatomic) UILabel *mingchengLabe; // 名称
@property(strong,nonatomic) UILabel *celvLabe;  // 厕率
@property(strong,nonatomic) UILabel *renshuLabel;  // 人数
@property(strong,nonatomic) UILabel *fenchengLabel; // 分成



@property(strong,nonatomic) UIView *diErGeView;
@property(strong,nonatomic) UICollectionView *maincollectionView;

// 游戏详情
@property(strong,nonatomic) UIView *youxixiangqingView;
@property(strong,nonatomic) UILabel *leirongLabel;
@property(assign,nonatomic) CGFloat gaodu;


// 等级Uiview
@property(strong,nonatomic)UIView *dengjilevelView;


// 猜你喜欢Uiview
@property(strong,nonatomic)UIView *cangnixihuanView;



@property(strong,nonatomic) NSDictionary *dataDic;
@property(strong,nonatomic) NSArray *imgsArr;





@end

@implementation HWGameDetailsViewController


-(UITableView *)mainaTableVie {
    
    if  (_mainaTableVie == nil) {
        
        _mainaTableVie = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, kScreenH - NavBarHeight) style:UITableViewStylePlain];
        // _mainaTableVie = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, kScreenH-44) style:UITableViewStylePlain];
     //   _mainaTableVie.contentInset = UIEdgeInsetsMake(0, 0, 0, 0);
        _mainaTableVie.delegate = self;
        _mainaTableVie.dataSource = self;
        _mainaTableVie.separatorStyle = UITableViewCellSeparatorStyleNone;
        _mainaTableVie.backgroundColor = beijingyanSe;
        _mainaTableVie.layer.cornerRadius = 12;
        _mainaTableVie.layer.masksToBounds = YES;
        _mainaTableVie.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
       // _mainaTableVie.backgroundColor = [UIColor whiteColor];
    }
    
    
    return   _mainaTableVie;
    
}
- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    [self.navigationController setNavigationBarHidden:NO animated:animated];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    // 添加常用的属性
    [self CommonlyUsedAttributes];

    [self setupUI];
    // 发送网络请求
    [self sendNetworkRequest];
    
    
}



// 设置常用属性
- (void)CommonlyUsedAttributes {
    
    self.navigationItem.title = @"游戏详情";
    self.view.backgroundColor = beijingyanSe;
    
    
    
    
    
}




// 设置UI
- (void)setupUI {
    
    [self.view addSubview:self.mainaTableVie];
    [self.mainaTableVie mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.mas_equalTo(0);
        make.bottom.mas_equalTo(self.view.mas_safeAreaLayoutGuideBottom);
    }];
    [self addheaderView];
    
}

// 添加headerView
- (void)addheaderView {
    
     self.headerView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, kScreenH)];
     self.mainaTableVie.tableHeaderView = self.headerView;
     //头部1
     [self addtoubu1View];
     
     //第二个 Uiview
     [self adddiergelungbotup];
    
     // 第三个
     [self addyouxiangqingqingView];

}


- (void)addtoubu1View {
    self.shangmianView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, 98+30+20)];
    self.shangmianView.backgroundColor = [UIColor whiteColor];
    self.shangmianView.layer.cornerRadius = 8;
    self.shangmianView.layer.masksToBounds = YES;
    [self.headerView addSubview:self.shangmianView];
    self.icoImageView = [[UIImageView alloc]initWithFrame:CGRectMake(20, 30, 98, 98)];
    self.icoImageView.backgroundColor = [UIColor whiteColor];
    self.icoImageView.layer.cornerRadius = 8;
    self.icoImageView.layer.masksToBounds = YES;
    [self.shangmianView addSubview: self.icoImageView];
    
    
    UILabel *zongrenLabel1 = [[UILabel alloc]initWithFrame:CGRectMake(self.icoImageView.right+10, 30, 200, 25)];
//    zongrenLabel1.layer.cornerRadius = 60;
//    zongrenLabel1.layer.masksToBounds = YES;
    zongrenLabel1.font = [UIFont systemFontOfSize:18];
    zongrenLabel1.textColor = RGB(68, 68, 68);
    zongrenLabel1.textAlignment = NSTextAlignmentLeft;
    zongrenLabel1.backgroundColor =  [UIColor whiteColor];
    zongrenLabel1.text = @"1hchh";
    self.mingchengLabe = zongrenLabel1;
    
    [self.shangmianView addSubview:zongrenLabel1];
    
       UILabel *zongrenLabel2 = [[UILabel alloc]initWithFrame:CGRectMake(self.icoImageView.right+10, zongrenLabel1.bottom+6, kScreenW-140, 17)];
        zongrenLabel2.font = [UIFont systemFontOfSize:12];
        zongrenLabel2.textColor = RGB(193, 193, 203);
        zongrenLabel2.textAlignment = NSTextAlignmentLeft;
        zongrenLabel2.backgroundColor =  [UIColor whiteColor];
        zongrenLabel2.text = @"手游/策略";
    self.celvLabe = zongrenLabel2;
        [self.shangmianView addSubview:zongrenLabel2];
    
         UILabel *zongrenLabel3 = [[UILabel alloc]initWithFrame:CGRectMake(self.icoImageView.right+10, zongrenLabel2.bottom+6, kScreenW-140, 17)];
          zongrenLabel3.font = [UIFont systemFontOfSize:12];
          zongrenLabel3.textColor = RGB(193, 193, 203);
          zongrenLabel3.textAlignment = NSTextAlignmentLeft;
          zongrenLabel3.backgroundColor =  [UIColor whiteColor];
          zongrenLabel3.text = @"1200 人申请";
         self.renshuLabel = zongrenLabel3;
          [self.shangmianView addSubview:zongrenLabel3];
    
    
          UILabel *zongrenLabel4 = [[UILabel alloc]initWithFrame:CGRectMake(self.icoImageView.right+10, zongrenLabel3.bottom+6, 56, 22)];
          zongrenLabel4.font = [UIFont systemFontOfSize:12];
          zongrenLabel4.textColor = RGB(255, 255, 255);
          zongrenLabel4.textAlignment = NSTextAlignmentCenter;
           zongrenLabel4.backgroundColor =  RGB(85, 89, 234);
          zongrenLabel4.text = @"45%";
         zongrenLabel4.layer.cornerRadius = 11;
         zongrenLabel4.layer.masksToBounds = YES;
          self.fenchengLabel  = zongrenLabel4;
          [self.shangmianView addSubview:zongrenLabel4];
    
    
//    @property(strong,nonatomic) UILabel *mingchengLabe; // 名称
//    @property(strong,nonatomic) UILabel *celvLabe;  // 厕率
//    @property(strong,nonatomic) UILabel *renshuLabel;  // 人数
//    @property(strong,nonatomic) UILabel *fenchengLabel; // 分成

    
    
    
    

    
    

    
    
    
    
    
}



// 第二个轮播图

- (void)adddiergelungbotup {
    
    
    self.diErGeView = [[UIView alloc]initWithFrame:CGRectMake(0, self.shangmianView.bottom, kScreenW, 202*CFLScaleValue)];
    self.diErGeView.backgroundColor = [UIColor whiteColor];
    [self.headerView addSubview: self.diErGeView];
    
    UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
     layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
     layout.minimumLineSpacing = 8*CFLScaleValue;
  //   layout.minimumInteritemSpacing = 30;
     
     self.maincollectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(20, 0, kScreenW-20,202*CFLScaleValue) collectionViewLayout:layout];
     self.maincollectionView.showsHorizontalScrollIndicator = NO;
     self.maincollectionView.delegate = self;
     self.maincollectionView.dataSource = self;
    // self.maincollectionView.backgroundColor = RGB(217, 247, 250);
     self.maincollectionView.backgroundColor = [UIColor whiteColor];
     
     //self.maincollectionView.alwaysBounceHorizontal = YES;
     
     
   //  self.maincollectionView.contentInset = UIEdgeInsetsMake(6, 10, 6, 10);
     // [self.maincollectionView registerClass:[UICollectionReusableView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"HeaderView"];  //  一定要设置
     [self.maincollectionView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:@"cellID"];
   //  [self.maincollectionView  registerNib:[UINib nibWithNibName:@"HWJietuCollectionViewCell" bundle:nil] forCellWithReuseIdentifier:@"cellID"];
     
     //  [UINib nibWithNibName:@"HWShouYouCollectionViewCell" bundle:nil]
     
     self.maincollectionView.userInteractionEnabled = YES;
     [self.diErGeView  addSubview:self.maincollectionView];
    

    
}


// 游戏详情
- (void)addyouxiangqingqingView {
    
    self.youxixiangqingView = [[UIView alloc]initWithFrame:CGRectMake(0,  self.diErGeView.bottom, kScreenW, 100)];
    self.youxixiangqingView.backgroundColor = [UIColor whiteColor];
    [self.headerView addSubview:self.youxixiangqingView];
    
    UILabel *zongrenLabel1 = [[UILabel alloc]initWithFrame:CGRectMake(20, 20, 200, 25)];
    //    zongrenLabel1.layer.cornerRadius = 60;
    //    zongrenLabel1.layer.masksToBounds = YES;
        zongrenLabel1.font = [UIFont systemFontOfSize:18];
        zongrenLabel1.textColor = RGB(68, 68, 68);
        zongrenLabel1.textAlignment = NSTextAlignmentLeft;
        zongrenLabel1.backgroundColor =  [UIColor whiteColor];
        zongrenLabel1.text = @"游戏详情";
    [self.youxixiangqingView addSubview:zongrenLabel1];
    
    
    
     UILabel *leirongL = [[UILabel alloc]initWithFrame:CGRectMake(20, 45+8, kScreenW - 40, 40)];
    //    zongrenLabel1.layer.cornerRadius = 60;
    //    zongrenLabel1.layer.masksToBounds = YES;
        leirongL.font = [UIFont systemFontOfSize:12];
        leirongL.textColor = RGB(136, 136, 136);
        leirongL.textAlignment = NSTextAlignmentLeft;
        leirongL.backgroundColor =  [UIColor whiteColor];
        leirongL.text = @"游戏戏戏详情请戏详情请戏详情请戏详情请戏详情请戏详情请戏详情请戏详情请戏详情请戏详情请戏详情请戏详情请戏详情请戏详情请戏详情请戏详情请戏详情请戏详情请戏详情请戏详情请戏详情请戏详情请戏详情请戏详情请详情请戏详情请戏详情请戏详情请详情请游戏";
    leirongL.numberOfLines = 0;
    self.leirongLabel = leirongL;
    [self.youxixiangqingView addSubview:leirongL];
    
 
    
    
    
    
    
    
    
   
    
}








// 发送网络请求
- (void)sendNetworkRequest {
    
    
    
     
         NSString *tStr = [NSString stringWithFormat:@"%ld",[WMUtil getTimeSp]];
         NSString *uid =  [HWLocallyStoredData getLoginUserID];
         NSString *signStr = [NSString stringWithFormat:@"%@%@%@%@",uid,self.idStr,tStr,@"adesxloksy13s98adv"];
         NSString  *signStrMd5  =   [WMUtil md5HexDigest:signStr];
         NSDictionary *parametes = @{      @"ios" : @"1",
                                      @"ct" : @"app",
                                      @"ac" : @"game_info",
                                      @"t" : tStr,
                                      @"id" :self.idStr,
                                      @"uid":uid,
                                      @"sign" :signStrMd5
                                    };
        
        
            [HWWebUtils doGetWithParameters:parametes progress:nil success:^(id response) {
                  
                 

                  NSString *codeStr =  [NSString stringWithFormat:@"%@",response[@"code"]];
                  if ([codeStr intValue] == 1) {
                 
                         NSLog(@"%@",response);
//                      
//                      self.dataMutableArr =   [response[@"data"] mutableCopy];
//                      [self.mainTabelView reloadData];
//
//
//                      
                      self.dataDic = response[@"data"];
    
                      self.imgsArr = (NSArray *)self.dataDic[@"imgs"];
                      [self shezhichangyongdekongjian];
                      
                      
                      
                      
                      
                       
                  } else {
                      
                    [MBProgressHUD showError:response[@"message"]];
                                    
                
                      
                  }
                  
             
                  
              } failure:^(NSString *error) {
                 // [SVProgressHUD dismiss];
                  
                   [MBProgressHUD showSuccess:@"登录失败"];
                  [MBProgressHUD hideHUD];
                  
                  
              }];
        
    
    
    
    
    
    
    
}

// 设置常用的控件

- (void)shezhichangyongdekongjian {
    
    
    //    @property(strong,nonatomic) UILabel *mingchengLabe; // 名称
    //    @property(strong,nonatomic) UILabel *celvLabe;  // 厕率
    //    @property(strong,nonatomic) UILabel *renshuLabel;  // 人数
    //    @property(strong,nonatomic) UILabel *fenchengLabel; // 分成
    
    
     NSString *icostr = [NSString stringWithFormat:@"%@",self.dataDic[@"icon"]];
     [self.icoImageView sd_setImageWithURL:[NSURL URLWithString:icostr] placeholderImage:nil];
    
     self.mingchengLabe.text = [NSString stringWithFormat:@"%@",self.dataDic[@"name"]];
     self.celvLabe.text = [NSString stringWithFormat:@"%@",self.dataDic[@"type"]];
     self.renshuLabel.text = [NSString stringWithFormat:@"%@人申请",self.dataDic[@"number"]];
     self.fenchengLabel.text = [NSString stringWithFormat:@"%@",self.dataDic[@"top_fcbl"]];
     [self.maincollectionView reloadData];
    
    
     CGFloat h = [self calculateRowHeight:self.dataDic[@"content"] fontSize:12];
    self.gaodu = h;
     self.youxixiangqingView.frame = CGRectMake(0,  self.diErGeView.bottom, kScreenW, 45+8 + h+10 );
    self.leirongLabel.frame =   CGRectMake(20, 45+8 , kScreenW-40, h);
    self.leirongLabel.text = [NSString stringWithFormat:@"%@",self.dataDic[@"content"]];
    
    
    // 等级Uiview
    [self adddengjiview];
    
    // 猜你喜欢
    [self addcainixihuanView];
    
    
    
    
    
    
    
}





- (void)adddengjiview {
    
    
    
    self.dengjilevelView  = [[UIView alloc]initWithFrame:CGRectMake(0, self.youxixiangqingView.bottom, kScreenW, 38*2)];
    self.dengjilevelView.backgroundColor = [UIColor whiteColor];
    [self.headerView addSubview: self.dengjilevelView];
    
    UIView   *kuankuanView  = [[UIView alloc]initWithFrame:CGRectMake(20, 0, kScreenW-40, 38*2)];
    kuankuanView.backgroundColor = [UIColor whiteColor];
    kuankuanView.layer.cornerRadius = 8;
    kuankuanView.layer.masksToBounds = YES;
    kuankuanView.layer.borderWidth = 1;
    kuankuanView.layer.borderColor = RGB(236, 236, 236).CGColor;
    [ self.dengjilevelView  addSubview:kuankuanView];
    
    NSArray *arr = (NSArray *)self.dataDic[@"fcbl"];

      CGFloat W = kScreenW - 40;
      CGFloat H = 38;

       CGFloat meigelabeW = W / arr.count;

      for (int i = 0 ; i < arr.count; i++) {


            NSDictionary *dic = arr[i];


              UILabel   *userLabel = [[UILabel alloc]initWithFrame:CGRectMake(meigelabeW*i, 0, meigelabeW, H)];
              userLabel.text = [NSString stringWithFormat:@"%@",dic[@"title"]];
              userLabel.textAlignment =  NSTextAlignmentCenter;
              userLabel.textColor = RGB(0, 0, 0);
              userLabel.alpha = 0.65;
              userLabel .font = [UIFont systemFontOfSize:12];
              userLabel.hidden = NO;
            //  userLabel.backgroundColor = RGB(243, 243, 243);
              userLabel.backgroundColor =  [UIColor whiteColor];
              userLabel.numberOfLines = 2;
              [kuankuanView   addSubview: userLabel];

        }

        for (int i = 0 ; i < arr.count; i++) {


                NSDictionary *dic = arr[i];


                 UILabel   *userLabel1 = [[UILabel alloc]initWithFrame:CGRectMake(meigelabeW*i, 38, meigelabeW, H)];
                 userLabel1.text = [NSString stringWithFormat:@"%@",dic[@"fcbl"]];
                 userLabel1.textAlignment =  NSTextAlignmentCenter;
                 userLabel1.textColor = RGB(0, 0, 0);
              //   userLabel.alpha = 0.65;
                 userLabel1 .font = [UIFont systemFontOfSize:12];
                 userLabel1.hidden = NO;
               //  userLabel.backgroundColor = RGB(243, 243, 243);
                 userLabel1.backgroundColor =  [UIColor whiteColor];
                 userLabel1.numberOfLines = 2;
                 [kuankuanView   addSubview: userLabel1];

           }
    
    
    UIView  *fengexianView  = [[UIView alloc]initWithFrame:CGRectMake(0, 37, W, 1)];
    fengexianView.backgroundColor  = RGB(232, 232, 232);
    [kuankuanView addSubview:fengexianView];

    
    
    
    
    
    
}

// 猜你喜欢
- (void)addcainixihuanView {
    
    
    self.cangnixihuanView = [[UIView alloc]initWithFrame:CGRectMake(0, self.dengjilevelView.bottom, kScreenW, 20+25+44+6+17+10+44)];
    self.cangnixihuanView.backgroundColor = [UIColor whiteColor];
    [self.headerView addSubview: self.cangnixihuanView];
    
    
    UILabel   *userLabel1 = [[UILabel alloc]initWithFrame:CGRectMake(20, 20, 100, 25)];
    userLabel1.textAlignment =  NSTextAlignmentLeft;
    userLabel1.textColor = RGB(68 ,68 ,68);
    //   userLabel.alpha = 0.65;
    userLabel1 .font = [UIFont systemFontOfSize:12];
    userLabel1.text = @"猜你喜欢";
    [self.cangnixihuanView   addSubview: userLabel1];
        
    NSArray *gameArr = (NSArray *)self.dataDic[@"game"];
    
    NSInteger coun = gameArr.count;
    
    
      CGFloat hengjianjuLiin = (kScreenW -  55*coun -40)/(coun-1);
    
    
      if (coun == 1) {
       
           // hengjianjuLiin = (kScreenW -  55*coun -40);
           hengjianjuLiin = 10;
        
      }
     
           

       for (int i = 0 ; i < coun; i++) {
               
//                   int row = i/coun;
                   int line = i%coun;
//                   int shulian = (line*2+2) -1;

                   UIView *redview = [[UIView alloc]initWithFrame:CGRectMake(hengjianjuLiin*line+20+line*55, 45, 55,44+17+6 )];
                 
                 
                   redview.tag = i+100;
                   redview.backgroundColor = [UIColor whiteColor];
                  //   redview.backgroundColor = [UIColor redColor];
                  
              [self.cangnixihuanView addSubview:redview];
                   
                   
               
                   

                   
//                   UITapGestureRecognizer *tap1 = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(imviewTaKaifu:)];
//                   [redview addGestureRecognizer:tap1];
//
                    NSDictionary *dic =  gameArr[i];
                   UIImageView *imview = [[UIImageView alloc]initWithFrame:CGRectMake(5, 0,  44, 44)];
                 //  imview.image = [UIImage imageNamed:paihangbangcoArr[i]];
                   imview.userInteractionEnabled = YES;
                   imview.tag = i;
                   [redview addSubview:imview];
               
                   NSString *imageStr = dic[@"icon"];
                 
                 [imview sd_setImageWithURL:[NSURL URLWithString:imageStr]  placeholderImage:nil];
                 
                 
                   
                   
               
                   
                  // UILabel
                   UILabel *nameLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 50, 55, 17)];
                 
                   nameLabel.textAlignment = NSTextAlignmentCenter;
                   nameLabel.font = [UIFont systemFontOfSize:12];
                   nameLabel.textColor = RGB(68, 68, 68);
                  // nameLabel.text = [NSString stringWithFormat:@"111"];
           
                   [redview addSubview:nameLabel];
                   
                nameLabel.text =  [NSString stringWithFormat:@"%@",dic[@"name"]];
                //   [self.labelMuArr addObject:nameLabel];
                   
               
        }
    
    
    
    UIButton *wangjibutton = [UIButton buttonWithType:UIButtonTypeCustom];
      wangjibutton.frame = CGRectMake(20,20+25+44+6+17+10,kScreenW-40, 44);
      [wangjibutton setTitle:@"一键申请" forState:UIControlStateNormal];
      [wangjibutton setTitleColor:RGB(255, 255, 255) forState:UIControlStateNormal];
      wangjibutton.titleLabel.font = [UIFont systemFontOfSize:12];
      [wangjibutton addTarget:self action:@selector(jiesuanbuttonTap) forControlEvents:UIControlEventTouchUpInside];
    
      wangjibutton.backgroundColor =  RGB(85, 89, 234);
      
     // wangjibutton.backgroundColor = [UIColor redColor];
    [self.cangnixihuanView addSubview:wangjibutton];
       
    
    self.headerView.frame = CGRectMake(0, 0, kScreenW, self.cangnixihuanView.bottom);
    self.mainaTableVie.tableHeaderView = self.headerView;
    
    
    
    
    
}






- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    
    
    return  0;
    
    
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    static NSString *cellID = @"cellID";
    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    
    if (!cell) {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
    }
    
    
    return  cell;
    
    
}





- (CGFloat)calculateRowHeight:(NSString *)string fontSize:(NSInteger)fontSize

{
    
    NSDictionary *dic = @{NSFontAttributeName:[UIFont systemFontOfSize:fontSize]};
    
    
    
    CGRect rect = [string boundingRectWithSize:CGSizeMake(kScreenW-40, MAXFLOAT)/*计算高度要先指定宽度*/ options:NSStringDrawingUsesLineFragmentOrigin |
                   
                   NSStringDrawingUsesFontLeading attributes:dic context:nil];
    
    return rect.size.height;
    
}





#pragma mark  ------------- UICollectionViewDataSource

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    return self.imgsArr.count;
}


- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    
    UICollectionViewCell *cell =  [collectionView dequeueReusableCellWithReuseIdentifier:@"cellID" forIndexPath:indexPath];
 //   NSString *icoStr = self.dataDic[@"imgs"][indexPath.row];
  //  NSURL *url = [NSURL URLWithString:icoStr];
    //[cell.jietuIcoimasgeView sd_setImageWithURL:url];
    UIImageView *iamgeView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 142*CFLScaleValue, 202*CFLScaleValue)];
    
    
    [cell.contentView addSubview:iamgeView];
    
    NSString *imagStr  =   self.imgsArr[indexPath.row];
    
    [iamgeView sd_setImageWithURL:[NSURL URLWithString:imagStr] placeholderImage:nil];
    
    
    
    
    
//    if (indexPath.row%2) {
//        cell.backgroundColor = [UIColor redColor];
//    } else {
//        
//         cell.backgroundColor = [UIColor yellowColor];
//        
//    }


    return cell;
    
    
}

- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
    
    return CGSizeMake(142*CFLScaleValue,202*CFLScaleValue);
}



- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
    
    DLog(@"点击精品手游单元格");
    
}



- (void)jiesuanbuttonTap {
    
    
    NSLog(@"dycbgdu");
    
    [self shengqingjiekou];
    
}


- (void)shengqingjiekou  {
    
    
    
             NSString *tStr = [NSString stringWithFormat:@"%ld",[WMUtil getTimeSp]];
              NSString *uid =  [HWLocallyStoredData getLoginUserID];
              NSString *signStr = [NSString stringWithFormat:@"%@%@%@%@",uid,self.idStr,tStr,@"adesxloksy13s98adv"];
              NSString  *signStrMd5  =   [WMUtil md5HexDigest:signStr];
              NSDictionary *parametes = @{      @"ios" : @"1",
                                           @"ct" : @"app",
                                           @"ac" : @"shenqing",
                                           @"t" : tStr,
                                           @"id" :self.idStr,
                                           @"uid":uid,
                                           @"sign" :signStrMd5
                                         };
    
                [MBProgressHUD showMessage:@"正在一键申请"];
             
             
                 [HWWebUtils doGetWithParameters:parametes progress:nil success:^(id response) {
                       
                      

                       NSString *codeStr =  [NSString stringWithFormat:@"%@",response[@"code"]];
                       [MBProgressHUD hideHUD];
                       if ([codeStr intValue] == 1) {
                      
                              NSLog(@"%@",response);
    
                           [self.navigationController popViewControllerAnimated:YES];
                           
                           
                            
                       } else {
                           
                         [MBProgressHUD showError:response[@"message"]];
                                         
                     
                           
                       }
                       
                  
                       
                   } failure:^(NSString *error) {
                      // [SVProgressHUD dismiss];
                       
                        [MBProgressHUD showSuccess:@"登录失败"];
                       [MBProgressHUD hideHUD];
                       
                       
                   }];
             
         
      
    
    
    
    
    
    
    
}


@end
